package com.yx.pay.wxpay.test;

import com.lijing.wechatpay.impl.PayImpl;
import com.yx.pay.wxpay.sdk.WXPayUtil;

public class WechatPay {

    /**
     * 公众号id：企业号corpid即为此appId
     */
    private String appId="wx83e895bd1ea53c4f";

    /**
     * 时间戳：当前时间10位随机数
     */
    private String timeStamp ;

    /**
     * 随机字符串：32位
     */
    private String nonceStr ;

    /**
     * 订单详情扩展字符串：统一下单接口返回的prepay_id参数值，提交格式如：prepay_id=***
     */
    private String prepay_id;

    /**
     *  签名方式：MD5
     */
    private String signType ;

    /**
     * 签名
     */
    private String paySign ;
    /*
    * trade_type为NATIVE时有返回，用于生成二维码，展示给用户进行扫码支付
    */
    private String code_url;
    /*
    * 订单id
    */
    private String out_trade_no;




    public WechatPay() {
    }


    public String getOut_trade_no() {
        return out_trade_no;
    }

    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(String timeStamp) {
        this.timeStamp = timeStamp;
    }

    public String getNonceStr() {
        return nonceStr;
    }

    public void setNonceStr(String nonceStr) {
        this.nonceStr = nonceStr;
    }



    public String getPrepay_id() {
        return prepay_id;
    }

    public void setPrepay_id(String prepay_id) {
        this.prepay_id = prepay_id;
    }

    public String getSignType() {
        return signType;
    }

    public void setSignType(String signType) {
        this.signType = signType;
    }

    public String getPaySign() {
        return paySign;
    }

    public void setPaySign(String paySign) {
        this.paySign = paySign;
    }

    public String getCode_url() {
        return code_url;
    }

    public void setCode_url(String code_url) {
        this.code_url = code_url;
    }

    public static WechatPay getWechatPay(UniteOrderResult result){
        WechatPay wechatPay = new WechatPay();
        wechatPay.setAppId(result.getAppid());
        wechatPay.setNonceStr(WXPayUtil.generateNonceStr());
        wechatPay.setSignType("MD5");
        wechatPay.setPrepay_id("prepay_id="+result.getPrepay_id());
        wechatPay.setTimeStamp(System.currentTimeMillis() + "");
        String sign = PayImpl.paySign(wechatPay, "F968E8E975723BE7C44DA2057C613860");
        wechatPay.setPaySign(sign);
        System.out.println("执行WechatPay成功！");
        return wechatPay ;
    }

}
